package com.example.gradu.graduationproject.controller;

import com.example.gradu.graduationproject.domain.FansUser;
import com.example.gradu.graduationproject.service.FansUserService;
import com.example.gradu.graduationproject.util.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (FansUser)表控制层
 * 所有关于粉丝列表(包含所有粉丝)的接口
 * @author makejava
 * @since 2025-02-20 23:02:34
 */
@RestController
@RequestMapping("fansUser")
public class FansUserController {
    /**
     * 服务对象
     */
    @Resource
    private FansUserService fansUserService;

    /**
     * 全查询
     *
     * @param fansUser 筛选条件
     * @return 查询结果
     */
    @GetMapping("queryAll")
    public R queryAll(FansUser fansUser) {
        return this.fansUserService.queryAll(fansUser);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R queryById(@PathVariable("id") Integer id) {
        return this.fansUserService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param fansUser 实体
     * @return 新增结果
     */
    @PostMapping("add")
    public R add(@RequestBody FansUser fansUser) {
        return this.fansUserService.insert(fansUser);
    }

    /**
     * 编辑数据
     *
     * @param fansUser 实体
     * @return 编辑结果
     */
    @PutMapping
    public R edit(@RequestBody FansUser fansUser) {
        return this.fansUserService.update(fansUser);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("delete")
    public R deleteById(Integer id) {
        return this.fansUserService.deleteById(id);
    }

}


